#include <iostream>
#include <cstring>

using namespace std;

int DNA[10];
int a[42], b[42];
int ntest;

char cv (int x)
{
	if (x == 0) return ' ';
	if (x == 1) return '.';
	if (x == 2) return 'x';
	return 'W';
}

int main()
{
	cin >> ntest;
	while (ntest-- > 0)
	{
		for (int i = 0; i < 10; i++) cin >> DNA[i];

		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));

		a[20] = 1;

		for (int i = 0; i < 50; i++)
		{
			for (int j = 1; j <= 40; j++) cout << cv(a[j]);
			cout << endl;

			if (i == 49) break;

			for (int j = 1; j <= 40; j++)
			{
				int k = a[j-1] + a[j] + a[j+1];
				b[j] = DNA[k];
			}

			for (int j = 1; j <= 40; j++) a[j] = b[j];
		}
		if (ntest > 0) cout << endl;
	}
	return 0;
}
